package com.example.broadcastreceiver;

import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.util.Log;

public class MyNormalReceiver extends BroadcastReceiver {
    private final MainActivity activity;

    public MyNormalReceiver(MainActivity activity) {
        this.activity = activity;
    }

    @Override
    public void onReceive(Context context, Intent intent) {
        Log.i("MyNormalReceiver", "自定义的普通广播接收者，接收到了求救广播事件");
        if (intent != null) {
            String msg = intent.getStringExtra("msg");
            if (msg != null) {
                this.activity.setContent(msg);
            }


        }
    }
}
